<template>
	<view>
		<!-- <view style="padding: 10px;">
			<view @click="add" style="width: 50%;background-color: #fff;padding: 10px;display: flex;align-items: center;justify-content: center;">
				<u-icon color="#00aa00" :size="40" name="plus-circle"></u-icon>
				<text>添加发票抬头</text>
			</view>
		</view> -->
		<view
			style="margin-bottom: 10px;background-color: #fff;display: flex;justify-content: space-between;border-bottom: #eee 1px solid;padding: 10px;">
			<u-section title="可选发票抬头" :right="false" line-color="red" font-size="28"
				style="margin-top:30rpx;"></u-section>
			<view style="text-align: right;">
				<view @click="add" style="display: flex;align-items: center;justify-content: center;padding: 10px;">
					<u-icon color="#00aa00" :size="40" name="plus-circle"></u-icon>
					<text>添加</text>
				</view>
			</view>
		</view>
		<!-- <view style="margin-bottom: 10px; padding: 0 10px;display: flex;justify-content: space-between;background-color: #fff;">
			<view style="display: flex;align-items: center;">
				发票抬头列表
			</view>
				<view @click="add" style="display: flex;align-items: center;justify-content: center;padding: 10px;">
					<u-icon color="#00aa00" :size="40" name="plus-circle"></u-icon>
					<text>添加</text>
				</view>
		</view> -->
		<view v-for="(item,index) in list" :key="index" @click="goBack(item)" style="padding: 10px;background-color: #fff;display: flex;justify-content: space-between;margin-bottom: 10px;">
			<view >
				<view>{{item.cname}}</view>
				<view style="color: #aaa;font-size: 24rpx;margin-top: 10px;">
					{{item.ctype == 1 ? '个人' : '单位'}}
				</view>
			</view>
			<view @click.stop="edit(item)" style="display: flex;align-items: center; padding: 0 10px;">
				<u-icon name="edit-pen" :size="50" ></u-icon>
			</view>
		</view>
		<view class="page-box" v-if="!list.length"
			style="min-height: 50vh;width: 100%;display: flex;align-items: center;justify-content: center;">
			<view >
				<u-empty text="暂无开票抬头信息!" mode="list"></u-empty>
			</view>
		</view>
		
	</view>
</template>

<script>
	
	export default {

		data() {
			return {
				focus: false,
				remarks: '',
				value: 0,
				list: [],
				payMoney: 0,
				show: false,
				numShow: false,
				title: "重庆轻企信息技术有限公司（企业）",
				curCus: {},
				fpData: {},
				cusMoney: {
					flhxMoney: '0.00',
					cxhxMoney: '0.00'
				},
				query: {
					pageNo: 1,
					pageSize: 50
				},
				flag: '',
				model: {},
				selectList: []
			}
		},
		onLoad(params) {
			this.loadList()
			uni.$on('edit', (e) => {
				console.log(e,'11111222');
				this.loadList()
			})
		},
		methods: {
			goBack(item){
				uni.$emit('lookUp', item);
				uni.navigateBack({
					delta: 1,
				})
			},
			add(){
				uni.navigateTo({
					url: '/pages/btdm/index/user/invoice/edit',
				})
			},
			edit(item){
				uni.navigateTo({
					url: '/pages/btdm/index/user/invoice/edit?item=' + JSON.stringify(item),
				})
			},
			loadList() {
				this.query.cusCode = this.vuex_basCus.code
				// this.query.createBy=this.vuex_user.userCode
				this.$u.api.shop.ttlistData(this.query).then(res => {
			
					if (res.result == 'false') {
						uni.showToast({
							title: res.message,
							icon: 'none',
						});
					} else {
						this.list = res.list;
					}
				})
			
			},
			
		},


	}
</script>

<style lang="scss" scoped>
	page {
		width: 100%;
		height: 98%;
		text-align: center;
		overflow: scroll;
	}

	.item-menu-image {
		width: 100px;
		height: 85px;
	}

	textarea {
		width: 100%;
		height: 260rpx;
		background-color: #f7f7f7;
		line-height: 60rpx;
		// margin: 40rpx auto;
		padding: 20rpx;
	}
</style>